<template>
    <div>
      4554545
      <input type="button" @click="get()" value="点击测试一下自定义的get请求,请求本地的txt文件">
      <input type="button" @click="post()" value="点击测试一下自定义的post请求,请求本地的php文件">
    </div>
</template>
<script>
export default {
  name: 'ajax',
  data () {
    return {
      pageTitle: 'Hello Ajax'
    }
  },
  methods: {
    get: function () {
      console.log('request')
      this.$http.get('/static/a.txt').then(function (res) {
        alert(res.body)
      }, function () {
        console.log(' 请求失败')
      })
    },
    post: function () {
      console.log(' this is post test 测试一下 post 请求')
      this.$http.get('/static/demo_test_post.php',{name:'菜鸟教程',url:'http://www.baidu.com'},{emulateJSON:true}).then(function(res){
        alert(res.body)
      },function (res) {
        alert(res.status)
      })
    }
  }
}
</script>

<style>
.home{
    margin-top: 10%;
    font-size: 2.4em;
    font-weight: bold;
}
</style>
